
pkgname=sudo
pkgver=1.8.23
_pkgver=1.8.23
pkgrel=1
pkgdesc="Give certain users the ability to run some commands as root."
arch=('x86_64')
url="https://www.sudo.ws/sudo/"
license=('custom')
depends=('glibc' 'pam' 'libldap')
backup=('etc/sudoers' 'etc/pam.d/sudo')
options=('!libtool')
source=("https://www.sudo.ws/dist/${pkgname}-${_pkgver}.tar.gz"
        'sudo.pam')
sha256sums=('d863d29b6fc87bc784a3223350e2b28a2ff2c4738f0fb8f1c92bb38c3017e679'
            'd1738818070684a5d2c9b26224906aad69a4fea77aabd960fc2675aee2df1fa2')

build() {
  cd ${pkgname}-${_pkgver}

  ./configure --prefix=/usr \
              --with-pam \
              --libexecdir=/usr/lib \
              --with-ldap \
              --with-ldap-conf-file=/etc/openldap/ldap.conf \
              --with-rundir=/run/sudo \
              --with-env-editor \
              --with-all-insults \
              --with-logfac=auth \
              --enable-tmpfiles.d 

  make
}

check() {
  cd ${pkgname}-${_pkgver}
  
  make check
}

package() {
  cd ${pkgname}-${_pkgver}

  # This is to ensure consistency with the permissions specified
  # in the 'filesystem' package.
  install -d -m755 ${pkgdir}/var/lib

  make DESTDIR=${pkgdir} install
  install -D -m644 ${srcdir}/sudo.pam ${pkgdir}/etc/pam.d/sudo
  
  # changes with 1.8.10, added .install for this
  rmdir ${pkgdir}/run/sudo
  rmdir ${pkgdir}/run

  install -D -m644 doc/LICENSE ${pkgdir}/usr/share/licenses/sudo/LICENSE
}

